<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template basic_event_composer</title>
<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../../index.html" title="Chapter 1. Boost.Log v2">
<link rel="up" href="../../../../sinks.html#header.boost.log.sinks.event_log_backend_hpp" title="Header &lt;boost/log/sinks/event_log_backend.hpp&gt;">
<link rel="prev" href="../drop_on_overflow.html" title="Class drop_on_overflow">
<link rel="next" href="custom_event_cate_idm33315.html" title="Class template custom_event_category_mapping">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../drop_on_overflow.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../../sinks.html#header.boost.log.sinks.event_log_backend_hpp"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="custom_event_cate_idm33315.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.log.sinks.event_log.basic_event_composer"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template basic_event_composer</span></h2>
<p>boost::log::sinks::event_log::basic_event_composer — An event composer. </p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../../sinks.html#header.boost.log.sinks.event_log_backend_hpp" title="Header &lt;boost/log/sinks/event_log_backend.hpp&gt;">boost/log/sinks/event_log_backend.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> CharT<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="basic_event_composer.html" title="Class template basic_event_composer">basic_event_composer</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">CharT</span>                          <a name="boost.log.sinks.event_log.basic_event_composer.char_type"></a><span class="identifier">char_type</span><span class="special">;</span>             <span class="comment">// Character type. </span>
  <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special">&lt;</span> <span class="identifier">char_type</span> <span class="special">&gt;</span> <a name="boost.log.sinks.event_log.basic_event_composer.string_type"></a><span class="identifier">string_type</span><span class="special">;</span>           <span class="comment">// String type to be used as a message text holder. </span>
  <span class="keyword">typedef</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span>                    <a name="boost.log.sinks.event_log.basic_event_composer.event_id_mapper_type"></a><span class="identifier">event_id_mapper_type</span><span class="special">;</span>  <span class="comment">// Event identifier mapper type. </span>
  <span class="keyword">typedef</span> <span class="identifier">basic_formatter</span><span class="special">&lt;</span> <span class="identifier">char_type</span> <span class="special">&gt;</span>   <a name="boost.log.sinks.event_log.basic_event_composer.formatter_type"></a><span class="identifier">formatter_type</span><span class="special">;</span>        <span class="comment">// Type of an insertion composer (a formatter) </span>
  <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="identifier">string_type</span> <span class="special">&gt;</span>     <a name="boost.log.sinks.event_log.basic_event_composer.insertion_list"></a><span class="identifier">insertion_list</span><span class="special">;</span>        <span class="comment">// Type of the composed insertions list. </span>

  <span class="comment">// <a class="link" href="basic_event_composer.html#boost.log.sinks.event_log.basic_event_composerconstruct-copy-destruct">construct/copy/destruct</a></span>
  <span class="keyword">explicit</span> <a class="link" href="basic_event_composer.html#idm33290-bb"><span class="identifier">basic_event_composer</span></a><span class="special">(</span><span class="identifier">event_id_mapper_type</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="basic_event_composer.html#idm33298-bb"><span class="identifier">basic_event_composer</span></a><span class="special">(</span><a class="link" href="basic_event_composer.html" title="Class template basic_event_composer">basic_event_composer</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="basic_event_composer.html" title="Class template basic_event_composer">basic_event_composer</a> <span class="special">&amp;</span> <a class="link" href="basic_event_composer.html#idm33307-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="basic_event_composer.html" title="Class template basic_event_composer">basic_event_composer</a><span class="special">)</span><span class="special">;</span>
  <a class="link" href="basic_event_composer.html#idm33304-bb"><span class="special">~</span><span class="identifier">basic_event_composer</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="basic_event_composer.html#idm33245-bb">public member functions</a></span>
  <span class="keyword">void</span> <a class="link" href="basic_event_composer.html#idm33246-bb"><span class="identifier">swap</span></a><span class="special">(</span><a class="link" href="basic_event_composer.html" title="Class template basic_event_composer">basic_event_composer</a> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">event_map_reference</span> <a class="link" href="basic_event_composer.html#idm33255-bb"><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span></a><span class="special">(</span><span class="identifier">event_id</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">event_map_reference</span> <a class="link" href="basic_event_composer.html#idm33264-bb"><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span></a><span class="special">(</span><span class="keyword">int</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">event_id</span> <a class="link" href="basic_event_composer.html#idm33273-bb"><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span></a><span class="special">(</span><span class="identifier">record_view</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">insertion_list</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idm67325"></a><h2>Description</h2>
<p>This class is a function object that extracts event identifier from the attribute values set and formats insertion strings for the particular event. Each insertion string is formatted with a distinct formatter, which can be created just like regular sinks formatters.</p>
<p>Before using, the composer must be initialized with the following information: </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>Event identifier extraction logic. One can use <code class="computeroutput">basic_direct_event_id_mapping</code> or <code class="computeroutput">basic_custom_event_id_mapping</code> classes in order to create such extractor and pass it to the composer constructor. </p></li>
<li class="listitem"><p>Event identifiers and insertion string formatters. The composer provides the following syntax to provide this information:</p></li>
</ul></div>
<p>
</p>
<pre class="programlisting"><span class="identifier">event_composer</span> <span class="identifier">comp</span><span class="special">;</span>
<span class="identifier">comp</span><span class="special">[</span><span class="identifier">MY_EVENT_ID1</span><span class="special">]</span> <span class="special">%</span> <span class="identifier">formatter1</span> <span class="special">%</span> <span class="special">...</span> <span class="special">%</span> <span class="identifier">formatterN</span><span class="special">;</span>
<span class="identifier">comp</span><span class="special">[</span><span class="identifier">MY_EVENT_ID2</span><span class="special">]</span> <span class="special">%</span> <span class="identifier">formatter1</span> <span class="special">%</span> <span class="special">...</span> <span class="special">%</span> <span class="identifier">formatterN</span><span class="special">;</span>
<span class="special">...</span>
</pre>
<p>The event identifiers in square brackets are provided by the message compiler generated header (the actual names are specified in the .mc file). The formatters represent the insertion strings that will be used to replace placeholders in event messages, thus the number and the order of the formatters must correspond to the message definition. </p>
<div class="refsect2">
<a name="idm67364"></a><h3>
<a name="boost.log.sinks.event_log.basic_event_composerconstruct-copy-destruct"></a><code class="computeroutput">basic_event_composer</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">explicit</span> <a name="idm33290-bb"></a><span class="identifier">basic_event_composer</span><span class="special">(</span><span class="identifier">event_id_mapper_type</span> <span class="keyword">const</span> <span class="special">&amp;</span> id_mapper<span class="special">)</span><span class="special">;</span></pre>
<p>Default constructor. Creates an empty map of events.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">id_mapper</code></span></p></td>
<td><p>An event identifier mapping function that will be used to extract event ID from attribute values </p></td>
</tr></tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idm33298-bb"></a><span class="identifier">basic_event_composer</span><span class="special">(</span><a class="link" href="basic_event_composer.html" title="Class template basic_event_composer">basic_event_composer</a> <span class="keyword">const</span> <span class="special">&amp;</span> that<span class="special">)</span><span class="special">;</span></pre>
<p>Copy constructor. Performs a deep copy of the object. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="basic_event_composer.html" title="Class template basic_event_composer">basic_event_composer</a> <span class="special">&amp;</span> <a name="idm33307-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="basic_event_composer.html" title="Class template basic_event_composer">basic_event_composer</a> that<span class="special">)</span><span class="special">;</span></pre>
<p>Assignment. Provides strong exception guarantee. </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idm33304-bb"></a><span class="special">~</span><span class="identifier">basic_event_composer</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Destructor </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idm67428"></a><h3>
<a name="idm33245-bb"></a><code class="computeroutput">basic_event_composer</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm33246-bb"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="basic_event_composer.html" title="Class template basic_event_composer">basic_event_composer</a> <span class="special">&amp;</span> that<span class="special">)</span><span class="special">;</span></pre>
<p>Swaps <code class="computeroutput">*this</code> and <code class="computeroutput">that</code> objects. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">event_map_reference</span> <a name="idm33255-bb"></a><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span><span class="special">(</span><span class="identifier">event_id</span> id<span class="special">)</span><span class="special">;</span></pre>
<p>Initiates creation of a new event description. The result of the operator can be used to add formatters for insertion strings construction. The returned reference type is implementation detail.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">id</code></span></p></td>
<td><p>Event identifier. </p></td>
</tr></tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">event_map_reference</span> <a name="idm33264-bb"></a><span class="keyword">operator</span><span class="special">[</span><span class="special">]</span><span class="special">(</span><span class="keyword">int</span> id<span class="special">)</span><span class="special">;</span></pre>
<p>Initiates creation of a new event description. The result of the operator can be used to add formatters for insertion strings construction. The returned reference type is implementation detail.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">id</code></span></p></td>
<td><p>Event identifier. </p></td>
</tr></tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">event_id</span> <a name="idm33273-bb"></a><span class="keyword">operator</span><span class="special">(</span><span class="special">)</span><span class="special">(</span><span class="identifier">record_view</span> <span class="keyword">const</span> <span class="special">&amp;</span> rec<span class="special">,</span> <span class="identifier">insertion_list</span> <span class="special">&amp;</span> insertions<span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>Event composition operator. Extracts an event identifier from the attribute values by calling event ID mapper. Then runs all formatters that were registered for the event with the extracted ID. The results of formatting are returned in the <span class="emphasis"><em>insertions</em></span> parameter.</p>
<p>

</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">insertions</code></span></p></td>
<td><p>A sequence of formatted insertion strings </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">rec</code></span></p></td>
<td><p>Log record view </p></td>
</tr>
</tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>An event identifier that was extracted from <code class="computeroutput">attributes</code> </p></td>
</tr>
</tbody>
</table></div>
</li>
</ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2007-2024 Andrey Semashev<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>).
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../drop_on_overflow.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../../sinks.html#header.boost.log.sinks.event_log_backend_hpp"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="custom_event_cate_idm33315.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
